{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "手机信息\n",
      "<__main__.YingTeercpu object at 0x0000022F0D7AA748>\n",
      "英特尔cpu\n",
      "android系统\n",
      "普通手机大手机壳\n"
     ]
    }
   ],
   "source": [
    "from abc import abstractmethod ,ABCMeta\n",
    "class PhoneShell(metaclass=ABCMeta):\n",
    "    @abstractmethod\n",
    "    def show_shell(self):\n",
    "        pass\n",
    "class CPU(metaclass=ABCMeta):\n",
    "    @abstractmethod\n",
    "    def show_cpu(self):\n",
    "        pass\n",
    "class OS(metaclass=ABCMeta):\n",
    "    @abstractmethod\n",
    "    def show_os(self):\n",
    "        pass\n",
    "class PhoneFactory(metaclass=ABCMeta):\n",
    "    @abstractmethod\n",
    "    def make_shell(self):\n",
    "        pass\n",
    "    @abstractmethod\n",
    "    def make_cpu(self):\n",
    "        pass\n",
    "    @abstractmethod\n",
    "    def make_os(self):\n",
    "        pass\n",
    "class SmallShell(PhoneShell):\n",
    "    def show_shell(self):\n",
    "        print('普通手机小手机壳')\n",
    "class Bigshell(PhoneShell):\n",
    "    def show_shell(self):\n",
    "        print('普通手机大手机壳')\n",
    "class Appleshell(PhoneShell):\n",
    "    def show_shell(self):\n",
    "        print('苹果手机壳')\n",
    "class Mediacpu(CPU):\n",
    "    def show_cpu(self):\n",
    "        print('联发科')\n",
    "class YingTeercpu(CPU):\n",
    "    def show_cpu(self):\n",
    "        print('英特尔cpu')\n",
    "        \n",
    "class Applecpu(CPU):\n",
    "    def show_cpu(self):\n",
    "        print('苹果cpu')\n",
    "class android(OS):\n",
    "    def show_os(self):\n",
    "        print('android系统')\n",
    "class IOS(OS):\n",
    "    def show_os(self):\n",
    "        print('ios系统')\n",
    "class mifactory(PhoneFactory):\n",
    "    def make_shell(self):\n",
    "        return SmallShell()\n",
    "    def make_cpu(self):\n",
    "        return Applecpu()\n",
    "    def make_os(self):\n",
    "        return android()\n",
    "class huaweiactory(PhoneFactory):\n",
    "    def make_shell(self):\n",
    "        return Bigshell()\n",
    "    def make_cpu(cpu):\n",
    "        return YingTeercpu()\n",
    "    def make_os(self):\n",
    "        return android()\n",
    "class phone():\n",
    "    def __init__(self,cpu,os,shell):\n",
    "        self.cpu=cpu\n",
    "        self.os=os\n",
    "        self.shell=shell\n",
    "    def show_info(self):\n",
    "        print('手机信息')\n",
    "        print(self.cpu)\n",
    "        self.cpu.show_cpu()\n",
    "        self.os.show_os()\n",
    "        self.shell.show_shell()\n",
    "def make_phone(factory):\n",
    "    cpu=factory.make_cpu()\n",
    "    os=factory.make_os()\n",
    "    shell=factory.make_shell()\n",
    "    return phone(cpu,os,shell)\n",
    "p1=make_phone(huaweiactory())\n",
    "p1.show_info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
